#!/usr/bin/perl

displayDir('e:/');

sub displayDir {
  my $dir = shift;
  
  opendir DIRHANDLE , $dir || die "Open dir $dir error!: $!";
  my @files = readdir DIRHANDLE || die "Read dir $dir error!: $!";
  closedir DIRHANDLE || die "Close dir $dir error!: $!";
  
  foreach $file (@files) {
    if(-d $file) {
      #displayDir($file);
      print "dir: ", $file, "\r\n";
    } else {
      print "file:", $file, "\r\n";
    }
  }  
}
